//
//  CommenBtnForImage.m
//  家校互通
//
//  Created by 李赛 on 15/6/17.
//  Copyright (c) 2015年 姬鑫宇. All rights reserved.
//

#import "CommenBtnForImage.h"

@implementation CommenBtnForImage
/**
 *  画自定义按钮，图片和文字
 *
 *  @param frame  总尺寸
 *  @param ImageString  图片名称
 *  @param titleName   需要设置btn的名字
 *  @param ImageWidth  图片宽度
 */
-(id)initWithFrame:(CGRect)frame withImageString:(NSString *)ImageString TitleName:(NSString *)titleName withImageWidth:(CGFloat )ImageWidth
{
    if (self) {
        self=[super initWithFrame:frame];
        UIView *holdView=[[UIView alloc]initWithFrame:CGRectMake((frame.size.width-80)/2, 0, 80, frame.size.height)];
    
        UIImageView *iconImage=[[UIImageView alloc]initWithFrame:CGRectMake(0, (frame.size.height-ImageWidth)/2, ImageWidth, ImageWidth)];
        iconImage.image=[UIImage imageNamed:ImageString];
        [holdView addSubview:iconImage];
        
        
        UILabel *titleLB=[[UILabel alloc]initWithFrame:CGRectMake(iconImage.frame.origin.x+ImageWidth+5, 0,80-iconImage.frame.origin.x-ImageWidth-5,frame.size.height)];
        titleLB.text=titleName;
        titleLB.textAlignment=NSTextAlignmentLeft;
        titleLB.font=[UIFont systemFontOfSize:12];
        titleLB.textColor=[UIColor darkGrayColor];
        [holdView addSubview:titleLB];
        [self addSubview: holdView];
        
//        UIView *seperateView=[[UIView alloc]initWithFrame:CGRectMake(frame.size.width-1, 5, 0.5, frame.size.height-10)];
//        seperateView.backgroundColor=[UIColor lightGrayColor];
//        seperateView.alpha=0.5;
        
//    
//        [self addSubview:seperateView];
    }
    return self;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
